import React, { Component } from "react";
import { NavLink } from "react-router-dom";
import RouterView from "../route/RouterView";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import * as action from "../../action/index";
export class Home extends Component {
  render() {
    let { navlinks, child ,zj} = this.props;

    return (
      <div>
        <div className="home">
          <div className="biao">
            {navlinks && navlinks.length > 0 ? (
              navlinks.map((item, index) => {
                return (
                  <div key={index}>
                    <NavLink
                      className="navlinks"
                      activeClassName="active"
                      to={item.path}
                    >
                      {item.name}
                    </NavLink>
                  </div>
                );
              })
            ) : (
              <div>暂无数据</div>
            )}
          </div>
          <RouterView RouterList={child} />
          <div>总价:{zj}</div>
        </div>
      </div>
    );
  }
}

const mapStateToProps = ({ RoduxList }) => {
  return {
    ...RoduxList,
  };
};

const mapDispatchToProps = (dispatch) => bindActionCreators(action, dispatch);

export default connect(mapStateToProps, mapDispatchToProps)(Home);
